//
//  MessageTableViewCell.m
//  HarmonizePub
//
//  Created by rzhy on 2016/11/28.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "MessageTableViewCell.h"
#import "Config.h"

@interface MessageTableViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *badge;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;

@end

@implementation MessageTableViewCell

+ (NSString *)registerName {
    return @"MessageTableViewCell";
}

+ (CGFloat)cellHeight {
    return 60.0f;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setCellShowDataWithDataDictionary:(NSDictionary *)dataDict {
//    XHLog(@"dataDict: %@", dataDict)
    [self setIconWithIcon:dataDict[@"image"]];
    self.titleLabel.text = dataDict[@"title"];
    self.timeLabel.text = dataDict[@"toSendTime"];
    self.contentLabel.text = dataDict[@"content"];
}

- (void)setIconWithIcon:(NSString *)icon {
    [self.iconView downloadImageWithURLString:icon placeholderString:@"MessageDefault.png"];
}

- (void)setIsRead:(BOOL)isRead {
    _isRead = isRead;
    self.badge.hidden = isRead;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _badge.layer.cornerRadius = _badge.frame.size.width / 2;
    _badge.layer.masksToBounds = YES;
//    XHLog(@"frame: %@", NSStringFromCGRect(_badge.frame))
}

@end
